package aad.storyboard.controller;

import aad.storyboard.model.AudioState;

/**Implementation of the State pattern for the AudioPlayer
  *
 */
public class AudioPausedState implements AudioState{
	
	 //define a instance to hold reference of Context Object (AudioPlayer)
    private AudioPlayer audioPlayer;
    
    //constructor should accept the context reference instance
    public AudioPausedState(AudioPlayer a){
        System.out.println("=== Paused State ===");
        audioPlayer = a;
    }
    
    //implementation of AudioPlayingState methods
    @Override
	public void playAudio()
    {
    	System.out.println("PLAYING STATE: ---");
    	audioPlayer.getPlayer().start();
        audioPlayer.setNewState(audioPlayer.getPlayingState());
    }
    @Override
	public void pauseAudio()
    {
    	System.out.println("Player is already Paused");
    }
    
    @Override
	public void stopAudio()
    {
    	System.out.println("STOPPED STATE: ---");
    	audioPlayer.getPlayer().stop();		
		audioPlayer.getPlayer().reset();		
        audioPlayer.setNewState(audioPlayer.getStoppedState());
    }
	@Override
	public void seekToPosition(int position) {
		System.out.println("SEEKING IN PAUSED STATE: ---");
		audioPlayer.getPlayer().start();
		audioPlayer.getPlayer().seekTo(position);
		audioPlayer.setNewState(audioPlayer.getPlayingState());
	}


}
